*test G&W with 1816-2000 data, onsets for originators only and for originators and joiners, ongoing iff new dispute, working in mydocs\gartzke: 6-11-12
*revised 6-26-12 to include 3 interactions; checked 9-25-12; minor addition 11-14-12

/*test Gartzke and Weisiger's results, modified cow2000\ray\tbl1&2cm.do, working in my docs\power: 3-13-12*/



set mem 350m
set seed 02061961


use "\\\asfs.asnet.ua-net.ua.edu\users$\home\joneal\My Documents\gartzke\dor_18162001_060712.dta", clear

stack statea year polity2a stateb year polity2b, into(state year polity2) clear
sort state year polity2
by state year: gen n=_n
keep if n==1
drop n
sort year

*by year: egen sd_dem=sd(polity2)

gen democ=1 if polity2>6.9 & polity2~=.
replace democ=0 if polity2<7

by year: egen propdem=mean(democ)

by year: gen n=_n
keep if n==1
sort year
keep year propdem
summ
corr
save propdem_060812, replace


use "\\\asfs.asnet.ua-net.ua.edu\users$\home\joneal\My Documents\gartzke\dor_18162001_060712.dta", clear

stack statea year cap_a stateb year cap_b, into(state year cap) clear
sort state year cap
by state year: gen n=_n
keep if n==1

summ cap, detail

*90th percentile is .0333



use "\\\asfs.asnet.ua-net.ua.edu\users$\home\joneal\My Documents\gartzke\dor_18162001_060712.dta", clear

desc
summ

sort year
merge year using propdem_060812
tab _m
drop _m
sort statea stateb year

summ propdem

*don't use G&W's modified polity score
*replace polity2a=(polity2a+10)/2
*replace polity2b=(polity2b+10)/2

gen smldem=polity2a if polity2a<=polity2b & polity2b~=.  
replace smldem=polity2b if polity2b<polity2a & polity2a~=.  
gen lrgdem=polity2b if polity2a<=polity2b & polity2b~=.  
replace lrgdem=polity2a if polity2b<polity2a & polity2a~=.  
drop dem*

/*calculate probability of winning using CINCs*/
gen smlcap=cap_a if cap_a<=cap_b & cap_b~=.  
replace smlcap=cap_b if cap_b<cap_a & cap_a~=.  
gen lrgcap=cap_b if cap_a<=cap_b & cap_b~=.  
replace lrgcap=cap_a if cap_b<cap_a & cap_a~=.  

gen pwin_lrg=lrgcap/(cap_a+cap_b)

gen dyadid=(statea*1000)+stateb

gen lndstab=ln(distance)

/*use Hegre's method for correcting for system size*/
gen lnNt=ln(numstate)
summ lnNt 
replace lnNt = lnNt - 3.135     
/*NB: 3.135 is minimum value of lnNt from previous summarize command.*/
replace lnNt = 0 if contig<6
sort statea stateb year

gen jtdem=1 if smldem>6 & smldem~=.
replace jtdem=0 if jtdem==. & smldem~=.
gen jtdemxpropdem=jtdem*propdem

gen jtaut=1 if lrgdem<-6
replace jtaut=0 if jtaut==. & lrgdem~=.
gen jtautxpropdem=jtaut*propdem

gen mixed=1 if smldem<-6 & lrgdem>6 & lrgdem~=.
replace mixed=0 if mixed==. & lrgdem~=.
gen mixedxpropdem=mixed*propdem

/*change contig variable from G&W so measures contiguity, not noncontiguity*/
gen contiguity=abs(contig-6)
corr contiguity contig
summ contiguity if statea==2 & stateb==20

/*change alliance variable from G&W so it measures being allied, not non-allied*/
gen allies=abs(alliance-4)
corr allies alliance
summ allies if statea==2 & stateb==365 & year==1968

sort statea stateb year

/*onset of all MIDs: originators only*/
btscs mzmid1_orig year dyadid, gen(py) nspline(3)
summ _spl* if py==3

estsimp logit mzmid1_orig jtdem jtaut mixed contiguity lndstab pwin_lrg lrgcap allies lnNt py _spline*, cluster(dyadid) nolog

setx jtdem 1 jtaut 0 mixed 0 contiguity 5 lndstab p10 allies 0 pwin_lrg .5 lrgcap .0333 lnNt 0 py 3 _spline1 -25.8 _spline2 -24.2 _spline3 -21.7
simqi, listx
setx jtdem 0 jtaut 1 mixed 0
simqi
setx jtdem 0 jtaut 0 mixed 1
simqi
drop b*

logit mzmid1_orig jtdem jtaut mixed propdem contiguity lndstab pwin_lrg lrgcap allies lnNt py _spline*, cluster(dyadid) nolog

estsimp logit mzmid1_orig jtdem propdem jtdemxpropdem jtaut jtautxpropdem mixed mixedxpropdem contiguity lndstab pwin_lrg lrgcap allies lnNt py _spline*, cluster(dyadid) nolog

setx jtdem 1 propdem .032 jtdemx .032 jtaut 0 jtautx 0 mixed 0 mixedxpropdem 0 contiguity 5 lndstab p10 allies 0 pwin_lrg .5 lrgcap .0333 lnNt 0 py 3 _spline1 -25.8 _spline2 -24.2 _spline3 -21.7
simqi, listx
setx jtdem 0 propdem .032 jtdemx 0 jtaut 1 jtautx .032 mixed 0 mixedxpropdem 0 
simqi
setx jtdem 0 propdem .032 jtdemx 0 jtaut 0 jtautx 0 mixed 1 mixedxpropdem .032
simqi

setx jtdem 1 propdem .427 jtdemx .427 jtaut 0 jtautx 0 mixed 0 mixedxpropdem 0 
simqi
setx jtdem 0 propdem .427 jtdemx 0 jtaut 1 jtautx .427 mixed 0 mixedxpropdem 0 
simqi
setx jtdem 0 propdem .427 jtdemx 0 jtaut 0 jtautx 0 mixed 1 mixedxpropdem .427
simqi

setx jtdem 1 propdem .641 jtdemx .641 jtaut 0 jtautx 0 mixed 0 mixedxpropdem 0 
simqi
setx jtdem 0 propdem .641 jtdemx 0 jtaut 1 jtautx .641 mixed 0 mixedxpropdem 0 
simqi
setx jtdem 0 propdem .641 jtdemx 0 jtaut 0 jtautx 0 mixed 1 mixedxpropdem .641
simqi
drop b*

drop  py _spl*



/*onset of fatal MIDs: originators only*/
btscs mzfatal1_orig year dyadid, gen(py) nspline(3)
summ _spl* if py==3

estsimp logit mzfatal1_orig jtdem jtaut mixed contiguity lndstab pwin_lrg lrgcap allies lnNt py _spline*, cluster(dyadid) nolog

setx jtdem 1 jtaut 0 mixed 0 contiguity 5 lndstab p10 allies 0 pwin_lrg .5 lrgcap .0333 lnNt 0 py 3 _spline1 -25.8 _spline2 -24.1 _spline3 -21.6
simqi, listx
setx jtdem 0 jtaut 1 mixed 0
simqi
setx jtdem 0 jtaut 0 mixed 1
simqi
drop b*

logit mzfatal1_orig jtdem jtaut mixed propdem contiguity lndstab pwin_lrg lrgcap allies lnNt py _spline*, cluster(dyadid) nolog

estsimp logit mzfatal1_orig jtdem propdem jtdemxpropdem jtaut jtautxpropdem mixed mixedxpropdem contiguity lndstab pwin_lrg lrgcap allies lnNt py _spline*, cluster(dyadid) nolog

setx jtdem 1 propdem .032 jtdemx .032 jtaut 0 jtautx 0 mixed 0 mixedxpropdem 0 contiguity 5 lndstab p10 allies 0 pwin_lrg .5 lrgcap .0333 lnNt 0 py 3 _spline1 -25.8 _spline2 -24.1 _spline3 -21.6
simqi, listx
setx jtdem 0 propdem .032 jtdemx 0 jtaut 1 jtautx .032 mixed 0 mixedxpropdem 0 
simqi
setx jtdem 0 propdem .032 jtdemx 0 jtaut 0 jtautx 0 mixed 1 mixedxpropdem .032
simqi

setx jtdem 1 propdem .427 jtdemx .427 jtaut 0 jtautx 0 mixed 0 mixedxpropdem 0 
simqi
setx jtdem 0 propdem .427 jtdemx 0 jtaut 1 jtautx .427 mixed 0 mixedxpropdem 0 
simqi
setx jtdem 0 propdem .427 jtdemx 0 jtaut 0 jtautx 0 mixed 1 mixedxpropdem .427
simqi

setx jtdem 1 propdem .641 jtdemx .641 jtaut 0 jtautx 0 mixed 0 mixedxpropdem 0 
simqi
setx jtdem 0 propdem .641 jtdemx 0 jtaut 1 jtautx .641 mixed 0 mixedxpropdem 0 
simqi
setx jtdem 0 propdem .641 jtdemx 0 jtaut 0 jtautx 0 mixed 1 mixedxpropdem .641
simqi
drop b*

drop  py _spl*


/*onset of all MIDs: originators and joiners*/
btscs mzmid1_all year dyadid, gen(py) nspline(3)
summ _spl* if py==3

estsimp logit mzmid1_all jtdem jtaut mixed contiguity lndstab pwin_lrg lrgcap allies lnNt py _spline*, cluster(dyadid) nolog

setx jtdem 1 jtaut 0 mixed 0 contiguity 5 lndstab p10 allies 0 pwin_lrg .5 lrgcap .0333 lnNt 0 py 3 _spline1 -25.8 _spline2 -24.2 _spline3 -21.9
simqi, listx
setx jtdem 0 jtaut 1 mixed 0
simqi
setx jtdem 0 jtaut 0 mixed 1
simqi
drop b*

logit mzmid1_all jtdem jtaut mixed propdem contiguity lndstab pwin_lrg lrgcap allies lnNt py _spline*, cluster(dyadid) nolog

estsimp logit mzmid1_all jtdem propdem jtdemxpropdem jtaut jtautxpropdem mixed mixedxpropdem contiguity lndstab pwin_lrg lrgcap allies lnNt py _spline*, cluster(dyadid) nolog

setx jtdem 1 propdem .032 jtdemx .032 jtaut 0 jtautx 0 mixed 0 mixedxpropdem 0 contiguity 5 lndstab p10 allies 0 pwin_lrg .5 lrgcap .0333 lnNt 0 py 3 _spline1 -25.8 _spline2 -24.2 _spline3 -21.9
simqi, listx
setx jtdem 0 propdem .032 jtdemx 0 jtaut 1 jtautx .032 mixed 0 mixedxpropdem 0 
simqi
setx jtdem 0 propdem .032 jtdemx 0 jtaut 0 jtautx 0 mixed 1 mixedxpropdem .032
simqi

setx jtdem 1 propdem .427 jtdemx .427 jtaut 0 jtautx 0 mixed 0 mixedxpropdem 0 
simqi
setx jtdem 0 propdem .427 jtdemx 0 jtaut 1 jtautx .427 mixed 0 mixedxpropdem 0 
simqi
setx jtdem 0 propdem .427 jtdemx 0 jtaut 0 jtautx 0 mixed 1 mixedxpropdem .427
simqi

setx jtdem 1 propdem .641 jtdemx .641 jtaut 0 jtautx 0 mixed 0 mixedxpropdem 0 
simqi
setx jtdem 0 propdem .641 jtdemx 0 jtaut 1 jtautx .641 mixed 0 mixedxpropdem 0 
simqi
setx jtdem 0 propdem .641 jtdemx 0 jtaut 0 jtautx 0 mixed 1 mixedxpropdem .641
simqi
drop b*

drop  py _spl*



/*onset of fatal MIDs: originators and joiners*/
btscs mzfatal1_all year dyadid, gen(py) nspline(3)
summ _spl* if py==3

estsimp logit mzfatal1_all jtdem jtaut mixed contiguity lndstab pwin_lrg lrgcap allies lnNt py _spline*, cluster(dyadid) nolog

setx jtdem 1 jtaut 0 mixed 0 contiguity 5 lndstab p10 allies 0 pwin_lrg .5 lrgcap .0333 lnNt 0 py 3 _spline1 -25.8 _spline2 -24.1 _spline3 -21.6
simqi, listx
setx jtdem 0 jtaut 1 mixed 0
simqi
setx jtdem 0 jtaut 0 mixed 1
simqi
drop b*

logit mzfatal1_all jtdem jtaut mixed propdem contiguity lndstab pwin_lrg lrgcap allies lnNt py _spline*, cluster(dyadid) nolog

estsimp logit mzfatal1_all jtdem propdem jtdemxpropdem jtaut jtautxpropdem mixed mixedxpropdem contiguity lndstab pwin_lrg lrgcap allies lnNt py _spline*, cluster(dyadid) nolog

setx jtdem 1 propdem .032 jtdemx .032 jtaut 0 jtautx 0 mixed 0 mixedxpropdem 0 contiguity 5 lndstab p10 allies 0 pwin_lrg .5 lrgcap .0333 lnNt 0 py 3 _spline1 -25.8 _spline2 -24.2 _spline3 -21.6
simqi, listx
setx jtdem 0 propdem .032 jtdemx 0 jtaut 1 jtautx .032 mixed 0 mixedxpropdem 0 
simqi
setx jtdem 0 propdem .032 jtdemx 0 jtaut 0 jtautx 0 mixed 1 mixedxpropdem .032
simqi

setx jtdem 1 propdem .427 jtdemx .427 jtaut 0 jtautx 0 mixed 0 mixedxpropdem 0 
simqi
setx jtdem 0 propdem .427 jtdemx 0 jtaut 1 jtautx .427 mixed 0 mixedxpropdem 0 
simqi
setx jtdem 0 propdem .427 jtdemx 0 jtaut 0 jtautx 0 mixed 1 mixedxpropdem .427
simqi

setx jtdem 1 propdem .641 jtdemx .641 jtaut 0 jtautx 0 mixed 0 mixedxpropdem 0 
simqi
setx jtdem 0 propdem .641 jtdemx 0 jtaut 1 jtautx .641 mixed 0 mixedxpropdem 0 
simqi
setx jtdem 0 propdem .641 jtdemx 0 jtaut 0 jtautx 0 mixed 1 mixedxpropdem .641
simqi



*use of lrgcap, rather than major power indicator, and inclusion of lnNt does not alter conclusions
gen majpower=1 if majpow1==1 | majpow2==1
replace majpower=0 if majpower==.

logit mzfatal1_all jtdem propdem jtdemxpropdem jtaut jtautxpropdem mixed mixedxpropdem contiguity lndstab pwin_lrg majpower allies py _spline*, cluster(dyadid) nolog




exit

